Declare @StartDate datetime
Declare @EndDate datetime

SET @StartDate = '2014-06-10 18:00:00.003'
SET @EndDate = '2014-06-11 18:00:00.000'

select Count(EmailID) from tblEmail Where EmailDirection = 1
And CreatedDate Between @StartDate And @EndDate

select top 10 * from tblDailyDetailReport Where Convert(varchar(6), EndDate, 112) = '201406'

Update tblDailyDetailReport SET DENOIE = 155 Where DDID = 85
Update tblDailyDetailReport SET DENOIE = 151 Where DDID = 86
Update tblDailyDetailReport SET DENOIE = 139 Where DDID = 87
Update tblDailyDetailReport SET DENOIE = 135 Where DDID = 88
Update tblDailyDetailReport SET DENOIE = 160 Where DDID = 89
Update tblDailyDetailReport SET DENOIE = 166 Where DDID = 90
Update tblDailyDetailReport SET DENOIE = 155 Where DDID = 91
Update tblDailyDetailReport SET DENOIE = 166 Where DDID = 92

		--DE "Total Outstanding (Open cases)"
		Select Count(CaseProfileIndex) From tblCaseProfileIndex 
		Where CaseSourceID = 2 And IsReplyCase = 0 And CaseStatus = 0

		--DE "Total Pending"
		Select Count(CaseProfileIndex) From tblCaseProfileIndex 
		Where CaseSourceID = 2 And IsReplyCase = 0 And CaseStatus = 1

select distinct E.EntityName, E.IsDummy As IsGenericEntity, CP.SurName, CP.Name from tblContactProfile CP
INNER JOIN tblEntity E ON CP.EntityID = E.EntityID
Where 
SurName LIKE 'na' OR Name LIKE 'na' 
or SurName LIKE 'n.a' OR Name LIKE 'n.a' 
Or SurName LIKE 'n/a' OR Name LIKE 'n/a' 
Order By E.EntityName

select count(*) from tblContactProfile